﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using TransportLayer;
using System.IO;
namespace TransportLayer.ExecNode
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main(string[] args)
        {
           if (!File.Exists(args[0]))
                return;
            TransportLayer.Node cNode = TransportLayer.Node.fopen(args[0]);
            File.Delete(args[0]);
            try
            {
                int mPort = Int32.Parse(args[1]);
         
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            if (cNode.Type == "switch" || cNode.Type == "matrix" || cNode.Type == "Switch" || cNode.Type == "Matrix")
                Application.Run(new NodeForm(cNode, mPort));
            else if (cNode.Type == "Source" || cNode.Type == "source")
                Application.Run(new SourceForm(cNode, mPort));
           else if (cNode.Type == "Sink" || cNode.Type == "sink")
                Application.Run(new SinkForm(cNode, mPort));
            }
            catch (FormatException) { return; }
            catch (NullReferenceException) { return; }
        }
    }
}
